
Option Explicit On
Option Strict On

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls


Partial Public Class TrackerSetup
	Inherits System.Web.UI.Page
	
	Sub Page_Load
		txtYear.Text = dateTime.Now.Year
		CheckPnlRunningVisibility(Me, New EventArgs())
		CheckPnlBikingVisibility(Me, New EventArgs())
		CheckPnlWalkingVisibility(Me, New EventArgs())
		CheckPnlSwimmingVisibility(Me, New EventArgs())
	End Sub
	
	Sub SwitchVisibilityForAllControlsAndContainer(c As WebControl, isVisible As Boolean)
		c.Enabled = isVisible
		Dim cc As Control
		For Each cc In c.Controls
			If TypeOf cc Is WebControl Then
				SwitchVisibilityForAllControlsAndContainer(DirectCast(cc, WebControl), isVisible)
			End If
		Next
	End Sub
	
	Sub CheckPnlRunningVisibility(sender As Object, e As EventArgs)
		SwitchVisibilityForAllControlsAndContainer(pnlRunning, chkRunning.Checked)
	End Sub
	
	Sub CheckPnlBikingVisibility(sender As Object, e As EventArgs) 
		SwitchVisibilityForAllControlsAndContainer(pnlBiking, chkBiking.Checked)
	End Sub
	
	Sub CheckPnlWalkingVisibility(sender As Object, e As EventArgs) 
		SwitchVisibilityForAllControlsAndContainer(pnlWalking, chkWalking.Checked)
	End Sub
	
	Sub CheckPnlSwimmingVisibility(sender As Object, e As EventArgs) 
		SwitchVisibilityForAllControlsAndContainer(pnlSwimming, chkSwimming.Checked)
	End Sub
	
	Sub NavigateBack(sender As Object, e As EventArgs) 
		Server.Transfer("Default.aspx")
	End Sub
	
	Sub ClearForm(sender As Object, e As EventArgs) 
		Server.Transfer("TrackerSetup.aspx")
	End Sub
	
	Sub NavigateNext(sender As Object, e As EventArgs)
		If rbGoals.Checked Then
			Server.Transfer("SetGoals.aspx")
		Else
			Server.Transfer("HomePage.aspx")
		End If
	End Sub
	
End Class
